<?php
namespace app\api\controller;

use app\api\model\ApplyModel;
use app\index\model\VisitorModel;
use app\api\model\FriendsModel;
use think\Db;

class Chat extends Base {
	/**
	 * [获取聊天室列表]
	 */
	public function getChatRoomList() {
		$list = DB::name("visitor_chatroom")->where([
			"visitor_ids" => ["like","%".$this->params['user+_id']."%"]
		])->field("id,chat_name,update_at,last_msg,last_vid,ct_path")->select();
		foreach($list as &$v){
			$v['head'] = $_SERVER['REQUEST_SCHEME']."://".$_SERVER['SERVER_NAME'].DB::name("home_visitor")->where("id",$v['last_vid'])->value("head");
			$v['update_at'] = date("Y-m-d H:i",$v['update_at']);
		}
	}
}
